/**
 * 
 */
package xj.toolkit.fsm.actors;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import xj.toolkit.ebus.EventBus;
import xj.toolkit.ebus.actors.MultiEventActor;
import xj.toolkit.fsm.FiniteStateMachine;
import xj.toolkit.util.ClosureEx;
import xj.toolkit.util.Functor;


/**
 * @author hp
 *
 */
public class FSMEventsActor extends MultiEventActor {
	
	private	FiniteStateMachine	fsm;
    
    public FSMEventsActor(EventBus ebus, String name, FiniteStateMachine fsm) {
		super(ebus, name);
		
		this.fsm = fsm;
	}

    public void setEvents(Collection<String> events) {
    	Map<String, ClosureEx> closures = new HashMap<String, ClosureEx>();
    	
    	Functor functor = new Functor(this.fsm, "acceptEvent");
    	for ( String event : events ) {
        	closures.put(event, functor);
    	}
    	
    	super.setClosures(closures);
    }
    
}
